package com.x.header;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * ClassName: HeaderController
 * Package: IntelliJ IDEA
 * Description:
 * Written by HanXu
 * Create 2024.09.11 22:10
 */
@Controller
@RequestMapping("header")
@ResponseBody
public class HeaderController {


    /**
     * @RequestHeader("Host") 指定要接收的请求头
     */
    @GetMapping("data")
    public String data(@RequestHeader("Host") String host){
        System.out.println("host = " + host);
        return "host = " + host;
    }
}
